package cn.flexui.flexuiserver.controller.web;

import cn.flexui.flexuiserver.common.ResponseResultGenerator;
import cn.flexui.flexuiserver.domain.Dict;
import cn.flexui.flexuiserver.domain.ResponseResult;
import cn.flexui.flexuiserver.domain.constant.OauthConts;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author wanmingyu
 * @create 2024/9/15 18:22
 */
@Tag(name = "字典")
@RestController
@Slf4j
@RequestMapping("/dic")
public class DictController {

    @Operation(summary = "三方认证类型")
    @GetMapping("/authType")
    public ResponseResult<List<Dict<String>>> authType() {
        List<Dict<String>> collect = Arrays.stream(OauthConts.AuthType.values()).map(dictEnum -> {
            Dict<String> dict = new Dict<>();
            dict.setKey(dictEnum.name());
            dict.setValue(dictEnum.getDesc());
            return dict;
        }).collect(Collectors.toList());
        return ResponseResultGenerator.success(collect);
    }
}
